package com.ruoyi.web.controller.echarts;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@RequestMapping("/echarts")
public class EchartsDataController extends BaseController {
   @GetMapping("/getString")
    public AjaxResult getAString(){
//        AjaxResult ajax =
        return  AjaxResult.success("成功获取一个字符串","hello world");
    }

    @GetMapping("/getXAxisData")
    public AjaxResult getXAxisData(){
        AjaxResult ajax=new AjaxResult();
        ajax.put("msg","获取x轴数据");
        List<String> monthList= new ArrayList<String>();
        for(int i=1;i<=6;i++){
           monthList.add(i+"月");
        }
        ajax.put("data",monthList);
       return ajax;
    }

    @RequestMapping(value = "/getYAxisData")
    public AjaxResult getYAxisData(){
       List<Integer> salesList= new ArrayList<>();
        Random r=new Random();
       for(int i=0;i<=6;i++){
          salesList.add(r.nextInt((i+1)*100)) ;
       }
       return AjaxResult.success(salesList);
    }
}
